/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.oimwrapper.testers;

import Thor.API.Operations.tcEmailOperationsIntf;
import Thor.API.Operations.tcFormDefinitionOperationsIntf;
import Thor.API.Operations.tcFormInstanceOperationsIntf;
import Thor.API.Operations.tcObjectOperationsIntf;
import Thor.API.tcResultSet;
import com.thortech.util.logging.Logger;
import java.util.HashMap;
import org.junit.Test;
import org.oimwrapper.connectors.OIMAdapterBase;
import org.oimwrapper.connectors.OIMRemoteClientBase;
import org.oimwrapper.connectors.internal.OIMObjectFormUtilities;
import org.oimwrapper.connectors.internal.OIMUtilityGetter;

/**
 *
 */
public class ClientEmailTester extends ClientBaseTester {

    
    private static final Logger logger = Logger.getLogger(ClientGenericRequestTester.class.getName());
    //private static final String childRoleTableName = "Lookup.ChildRoleTableName";

    private static OIMAdapterBase apiBase;
    private OIMRemoteClientBase tester;
    
    private tcFormInstanceOperationsIntf formInstOps;
    private tcFormDefinitionOperationsIntf formDefOps;
    private tcObjectOperationsIntf objectOp;
    private OIMObjectFormUtilities objFormUtils;
    private tcEmailOperationsIntf mailOp;
    
    
    @Test
    public void mainTest()
    {
        try {
            tester = this.connect();
            apiBase = tester.getUtils();
            formInstOps = (tcFormInstanceOperationsIntf)apiBase.getUtility(Thor.API.Operations.tcFormInstanceOperationsIntf.class);
            formDefOps = (tcFormDefinitionOperationsIntf)apiBase.getUtility(Thor.API.Operations.tcFormDefinitionOperationsIntf.class);
            objectOp = (tcObjectOperationsIntf)apiBase.getUtility(Thor.API.Operations.tcObjectOperationsIntf.class);
            objFormUtils = OIMUtilityGetter.getObjectFormUtilities(logger, objectOp,formInstOps, formDefOps);
            mailOp = (tcEmailOperationsIntf)apiBase.getUtility(Thor.API.Operations.tcEmailOperationsIntf.class);
        } catch (Exception ex) {
            logger.error("Exception",ex);
            return;
        }
        
        try
        {
            HashMap filter = new HashMap();
            filter.put("Email Definition.Name","New EmailDef");
            tcResultSet rs = mailOp.findEmailDefinition(filter);
            filter.put("Email Definition.Key","");
            printResultSet(rs,filter);
        }
        catch(Exception e)
        {
            logger.error("APIError",e);
        }
        
    }
}
